<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Student extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct()
    {
        parent::__construct();
        $this->load->model('student_model');
        if(!$this->session->userdata('is_logged_in')){
            redirect('admin/login');
        }
    }
 
    
public function index()
    {

        //all the posts sent by the view
        $academic_session = $this->input->post('academic_session'); 
        $group_id=$this->input->post('group_id'); 
        $search_string = $this->input->post('search_string');        
        $order = $this->input->post('order'); 
        $order_type = $this->input->post('order_type');
	
        //pagination settings
        $config['per_page'] = 50;
        $config['base_url'] = base_url().'index.php/admin/student';
        $config['use_page_numbers'] = TRUE;
        $config['num_links'] = 20;
        $config['full_tag_open'] = '<ul>';
        $config['full_tag_close'] = '</ul>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a>';
        $config['cur_tag_close'] = '</a></li>';
        //initializate the panination helper 
        //$this->pagination->initialize($config);   
        
	//limit end
        $page = $this->uri->segment(3);

        //math to get the initial record to be select in the database
        $limit_end = ($page * $config['per_page']) - $config['per_page'];
        if ($limit_end < 0){
            $limit_end = 0;
        } 

        //if order type was changed
        if($order_type){
            $filter_session_data['order_type'] = $order_type;
        }
        else{
            //we have something stored in the session? 
            if($this->session->userdata('order_type')){
                $order_type = $this->session->userdata('order_type');    
            }else{
                //if we have nothing inside session, so it's the default "Asc"
                $order_type = 'Asc';    
            }
        }
        //make the data type var avaible to our view
        $data['order_type_selected'] = $order_type;        


        //we must avoid a page reload with the previous session data
        //if any filter post was sent, then it's the first time we load the content
        //in this case we clean the session filter data
        //if any filter post was sent but we are in some page, we must load the session data
	//filtered && || paginated
        if($search_string !== false && $order !== false || $this->uri->segment(3) == true){ 
           
            /*
            The comments here are the same for line 79 until 99

            if post is not null, we store it in session data array
            if is null, we use the session data already stored
            we save order into the the var to load the view with the param already selected       
            */

            if($academic_session!=null){
                $filter_session_data['academic_session_selected'] = $academic_session;
            }else{
                $academic_session = $this->session->userdata('academic_session_selected');
                $filter_session_data['academic_session_selected']=$academic_session;
            }
            $data['academic_session_selected'] = $academic_session;

            if($group_id!=null)
            {
            	$filter_session_data['group_id_selected'] = $group_id;
            }
            else 
            {
              $group_id=$this->session->userdata('group_id_selected');
              $filter_session_data['group_id_selected'] = $group_id;
            }
            $data['group_id_selected'] =$group_id;
             
            if($search_string){
                $filter_session_data['search_string_selected'] = $search_string;
            }else{
                $search_string = $this->session->userdata('search_string_selected');
            }
            $data['search_string_selected'] = $search_string;

            if($order){
                $filter_session_data['order'] = $order;
            }
            else{
                $order = $this->session->userdata('order');
            }
            $data['order'] = $order;

            //save session data into the session
            $this->session->set_userdata($filter_session_data);

            //fetch student data into arrays
            //$data['sessions'] = $this->student_model->get_session_ids();

            $data['count_students']= $this->student_model->count_students($academic_session, $group_id,$search_string, $order);
            $config['total_rows'] = $data['count_students'];

            //fetch sql data into arrays
            if($search_string){
                if($order){
                    $data['students'] = $this->student_model->get_students($academic_session,$group_id, $search_string, $order, $order_type, $config['per_page'],$limit_end);        
                }else{
                }
            }else{
                if($order){
                    $data['students'] = $this->student_model->get_students($academic_session, $group_id,'', $order, $order_type, $config['per_page'],$limit_end);        
                }else{
                    $data['students'] = $this->student_model->get_students($academic_session, $group_id,'', '', $order_type, $config['per_page'],$limit_end);        
                }
            }

        }else{

            //clean filter data inside section
        	$academic_session="2013-2015";
            $filter_session_data['academic_session_selected'] = $academic_session ;
            $group_id="Humanities";
            $filter_session_data['group_id_selected'] =$group_id;
            $filter_session_data['search_string_selected'] = null;
            $filter_session_data['order'] = null;
            $filter_session_data['order_type'] = null;
            $this->session->set_userdata($filter_session_data);

            //pre selected options
            $data['search_string_selected'] = '';
            $data['academic_session_selected'] =$academic_session;
            $data['group_id_selected'] =$group_id;
            $data['order'] = 'id';

            //fetch sql data into arrays
            //$data['sessions'] =  $this->student_model->get_session_ids();
            $data['count_students']= $this->student_model->count_students($academic_session,$group_id);
            $data['students'] = $this->student_model->get_students($academic_session, $group_id,'', '', $order_type, $config['per_page'],$limit_end);        
            $config['total_rows'] = $data['count_students'];

        }//!isset($manufacture_id) && !isset($search_string) && !isset($order)
	
        $this->pagination->initialize($config);
        //load the view
        $data['main_content'] = 'admin/student/list';
        $this->load->view('includes/template2', $data);  

    }//index

    public function add()
    {
        //if save button was clicked, get the data sent via post
        if ($this->input->server('REQUEST_METHOD') === 'POST')
        {

            //form validation
            $this->form_validation->set_rules('STUDENT_NAME', 'STUDENT_NAME', 'required');
            $this->form_validation->set_rules('FATHERNAME', 'FATHERNAME', 'required');
            $this->form_validation->set_rules('MOTHERNAME', 'MOTHERNAME', 'required');
            $this->form_validation->set_rules('SEX', 'SEX', 'required');
            $this->form_validation->set_error_delimiters('<div class="alert alert-error"><a class="close" data-dismiss="alert">×</a><strong>', '</strong></div>');

            //if the form has passed through the validation
            if ($this->form_validation->run())
            {
                $data_to_insert = array(
                    'STUDENT_NAME' => $this->input->post('STUDENT_NAME'),
                    'FATHERNAME' => $this->input->post('FATHERNAME'),
                    'MOTHERNAME' => $this->input->post('MOTHERNAME'),
                    'SEX' => $this->input->post('SEX')
                );
                //if the insert has returned true then we show the flash message
                if($this->student_model->insert_student($data_to_insert)){
                    $data['flash_message'] = TRUE; 
                }else{
                    $data['flash_message'] = FALSE; 
                }

            }

        }
        //fetch manufactures data to populate the select field
       
        //load the view
        $data['main_content'] = 'admin/student/add';
        $this->load->view('includes/template2', $data);  
    }       
	///////////////////////////////////////////
	/**
    * Update item by his id
    * @return void
    */
    public function std_modify_ginfo_view()
    {
        $student_id = $this->uri->segment(4);
        $academic_session=$this->uri->segment(3);

        //product data 
        $data['student'] = $this->student_model->get_student_by_id($student_id,$academic_session);
        $data['edu'] = $this->student_model->get_student_edu_by_id($student_id,$academic_session);
        
        //fetch manufactures data to populate the select field
        //load the view
        $data['main_content'] = 'admin/student/edit';
        $this->load->view('includes/template2', $data);            

    }//update
    public function edit_std_general_info()
    {
    	//error_log("validation start...", 3, "my-errors.log");
    	$return = array();
    	$return['msg'] = '';
    	$return['error'] = false;
    	try{
    		//form validation
    		$this->load->library('form_validation');
    		$this->form_validation->set_rules('student_name', 'student_name', 'required');
    		$this->form_validation->set_rules('student_id', 'f_y_1st_ct', 'required');
    		$this->form_validation->set_rules('academic_session', 'f_y_1st_ht_mcq', 'required');
    		//if the form has passed through the validation
    		$student_id = $this->input->post('student_id');
    		$academic_session = $this->input->post('academic_session');
    		
    		if ($this->form_validation->run())
    		{
    			$data_for_update_general = array(
    					'student_name' => $this->input->post('student_name'),
    					'mother_lang' => $this->input->post('mother_lang'),
    					'fathername' => $this->input->post('fathername'),
    					'mothername' => $this->input->post('mothername'),
    					'dob' => $this->input->post('dob'),
    					'dateofadmission' => $this->input->post('dateofadmission'),
    					'presentaddress' => $this->input->post('presentaddress'),
    					'phone_reg' => $this->input->post('phone_reg'),
    					'phone_off' => $this->input->post('phone_off'),
    					'transfer_no' => $this->input->post('transfer_no'),
    					'trans_date' => $this->input->post('trans_date'),
    					'dropped' => $this->input->post('dropped'),
    					'drop_date' => $this->input->post('drop_date'),
    					'co_cur_activities' => $this->input->post('co_cur_activities'),
    					'remarks' => $this->input->post('remarks')
    			);
    			$data_for_update_edu = array(
    					'ssc_board' => $this->input->post('ssc_board'),
    					'ssc_year' => $this->input->post('ssc_year'),
    					'ssc_group' => $this->input->post('ssc_group'),
    					'ssc_reg_no' => $this->input->post('ssc_reg_no'),
    					'ssc_reg_year' => $this->input->post('ssc_reg_year'),
    					'ssc_centre' => $this->input->post('ssc_centre'),
    					'ssc_roll' => $this->input->post('ssc_roll'),
    					'ssc_gpa' => $this->input->post('ssc_gpa'),
    					'ssc_opt' => $this->input->post('ssc_opt'),
    					'ssc_school' => $this->input->post('ssc_school'),
    					'hsc_board' => $this->input->post('hsc_board'),
    					'hsc_year' => $this->input->post('hsc_year'),
    					'hsc_group' => $this->input->post('hsc_group'),
    					'hsc_reg_no' => $this->input->post('hsc_reg_no'),
    					'hsc_reg_year' => $this->input->post('hsc_reg_year'),
    					'hsc_centre' => $this->input->post('hsc_centre'),
    					'hsc_roll' => $this->input->post('hsc_roll'),
    					'hsc_gpa' => $this->input->post('hsc_gpa'),
    					'hsc_opt' => $this->input->post('hsc_opt'),
    					'hsc_medium' => $this->input->post('hsc_medium')
    			);
    	
    			if($this->student_model->update_std_general_info($student_id,$academic_session,$data_for_update_general)
    			&&  $this->student_model->update_std_edu_info($student_id,$academic_session,$data_for_update_edu))
    			{
    				$return['msg']="Update Succefully";
    			}
    			else{
    				$return['msg']="Update Failed";
    			}
    	
    		}//validation run
    		else{
    			$return['msg']=$this->form_validation->error_array();
    		}
    	}
    	catch(Exception $e)
    	{
    		$return['msg']=$e->getMessage();
    	}
    	
    	echo  json_encode($return);
    }
    ///////////////////////////////////////////
    function get_all_student($academic_session,$group_id)
    {
    	//$academic_session = $_GET['academic_session'] ;
    	
    	//pagination settings
    	$config['per_page'] = 300;
    	$config['base_url'] = base_url().'index.php/admin/get_all_student/'.$academic_session.'/'.$group_id;
    	$config['use_page_numbers'] = TRUE;
    	$config['num_links'] = 25;
    	$config['full_tag_open'] = '<ul>';
    	$config['full_tag_close'] = '</ul>';
    	$config['num_tag_open'] = '<li>';
    	$config['num_tag_close'] = '</li>';
    	$config['cur_tag_open'] = '<li class="active"><a>';
    	$config['cur_tag_close'] = '</a></li>';
    	$config['uri_segment']=5;
    	
    	$page = $this->uri->segment(5);    	
    	//math to get the initial record to be select in the database
    	$limit_end = ($page * $config['per_page']) - $config['per_page'];

    	if ($limit_end < 0){
    		$limit_end = 0;
    	}

    	$data['count_students']= $this->student_model->count_students($academic_session,$group_id);
    	$data['students'] = $this->student_model->get_students_with_option($academic_session,$group_id,$config['per_page'],$limit_end);
    	$config['total_rows'] = $data['count_students'];
    	
    	$this->pagination->initialize($config);
    	//load the view
    	$data['main_content'] = 'admin/student/select_all_student';
    	$this->load->view('includes/template2', $data);
    }
    ///////////////////////////////////////////
    function std_assign_subject()
    {
    	$data['main_content'] = 'admin/student/assign_subject_step1_view';
    	$this->load->view('includes/template2', $data);
    }
    ///////////////////////////////////////////
    function std_assign_core_subject()
    {
    	$academic_session=$_GET['academic_session'];
    	$core=1;
    	$code_subject=$this->student_model->get_subject($core);
    	$data['code_subject']=$code_subject;
    	$data['academic_session']=$academic_session;
    	$data['main_content'] = 'admin/student/std_assign_core_subject_view';
    	$this->load->view('includes/template2', $data);
    }
    //////////////////////////////////////////////////
    function individual_student_subject_view()
    {
    	$data['main_content'] = 'admin/student/individual_student_subject_view';
    	$this->load->view('includes/template', $data);
    }
    function show_subjects()
    {
    	$return = array();
    	$return['msg'] = '';
    	$return['error'] = false;
    	$academic_session=$this->input->post('academic_session');
    	$student_id=$this->input->post('student_id');
    	$group_id=$this->input->post('group_id');
    	 
    	 
    	$group_std_subjects=$this->student_model->get_group_std_subjects($academic_session,$group_id,$student_id);
    	 
    
    	$return['msg'] ="<table border='1' width='90%' style='text-align: center;padding-top: 40px'>
    			<tr><th>Subject ID</th><th>Subject Name</th><th>optional(1)</th><th>is assign</th></tr>";
    	$return['msg'].="<input type='hidden' name='student_id' value='".$student_id."' />";
    	$return['msg'].="<input type='hidden' name='academic_session' value='".$academic_session."' />";
    	 
    	foreach($group_std_subjects as $row)
    	{
    		$return['msg'].="<tr>";
    		$return['msg'].="<td>".$row['group_subject_id']."</td><td>".$row['subject_name']."</td>";
    		$return['msg'].="<td> <input type='text' name='opt_subjects[]' id='opt_".$row['group_subject_id']."' size='2' value='".$row['is_opt']."'></td>";
    		$return['msg'].="<input type='hidden' name='subjects[]' id='".$row['group_subject_id']."' value='".$row['group_subject_id']."'></td>";
    		if($row['group_subject_id']==$row['subject_id'])
    		{
    			$return['msg'].="<td><input type='checkbox' name='chk_subjects[]' id='chk_".$row['group_subject_id']."' value='1'  checked ></td>";
    		}
    		else
    		{
    			$return['msg'].="<td><input type='checkbox' name='chk_subjects[]' id='chk_".$row['group_subject_id']."' value='1' ></td>";
    		}
    		$return['msg'].="</tr>";
    	}
    
    
    	$return['msg'].="</table>";
    	$return['msg'].="<input type='submit'  value='Save changes' class='btn btn-primary'  size='10' />";
    	echo  json_encode($return);
    }
    ///////////////////////////////////////////
    ///////////////////////////////////////////
    function assign_std_subjects()
    {
    	$return = array();
    	$return['msg'] = 'Assign Subject Successfull';
    	$return['error'] = false;
    	$student_id=$this->input->post('student_id');
    	$academic_session=$this->input->post('academic_session');
    	$subjects = $this->input->post('subjects');
    	$chk_subjects = $this->input->post('chk_subjects');
    	$opt_subjects = $this->input->post('opt_subjects');
    	$flag=$this->student_model->assing_individual_std_subjects($student_id,$academic_session,$subjects,$chk_subjects,$opt_subjects);
    	 
    	/*$i=0;
    	 foreach( $subjects as $key => $sub_id )
    	 {
    	$return['msg'].=$subjects[$i]." ".$chk_subjects;
    	$i++;
    	}
    	*/
    	if($flag==0)
    		$return['msg'] = 'Assign Subject error';
    	echo  json_encode($return);
    }
    ///////////////////////////////////////////
    ///////////////////////////////////////////
    function store_std_core_subject()
    {
    	$return = array();
    	$return['msg'] = 'Assign Core Subject Successfull';
    	$return['error'] = false;
    	$count=0;
    	$academic_session=$this->input->post('academic_session');
    	$group_id="Science";
    	if($this->student_model->insert_std_core_subject($academic_session,$group_id))
    		$count=$count+1;
    	$group_id="Humanities";
    	if($this->student_model->insert_std_core_subject($academic_session,$group_id))
    		$count=$count+1;
    	$group_id="Business Studies";
    	if($this->student_model->insert_std_core_subject($academic_session,$group_id))
    		$count=$count+1;
    	
    	if($count!=0)
    		$return['msg'] ="Assign Core Subject Fail";
    	
    	echo  json_encode($return);
    }
    //////////////////////////////////////////
    function std_assign_optional_subject()
    {
    	$academic_session=$_GET['academic_session'];
    	$core=0;
    	$code_subject=$this->student_model->get_subject($core);
    	$data['code_subject']=$code_subject;
    	$data['academic_session']=$academic_session;
    	$data['main_content'] = 'admin/student/std_assign_optional_subject_view';
    	$this->load->view('includes/template2', $data);
    } 
    //////////////////////////////////////////
    function store_std_optional_or_core_subject()
    {
    	$return = array();
    	$return['msg'] = '';
    	$return['error'] = false;
    	$academic_session=$this->input->post('academic_session');
    	$group_id=$this->input->post('group_id');
    	$subject_id=$this->input->post('subject_id');
    	$is_opt=$this->input->post('subject_type');
    	$student_id=explode(',', $this->input->post('area_student_id'));
    
    	for($ind=0;$ind<sizeof($student_id);$ind++)
    	{
    		$data_to_insert = array(
    				'student_id' => $student_id[$ind],
    				'academic_session' => $academic_session,
    				'subject_id' => $subject_id,
    				'is_opt' =>$is_opt=='core_subj' ?null:1
    		);
    		if($student_id[$ind]!="" ||$student_id[$ind]!=null)
    		{
	    		if($this->student_model->insert_std_subject($data_to_insert)){
	    			$return['msg'] = "Assign Subject Successfull ";
	    		}else{
	    			$return['msg'] = "Assign Subject Fail";
	    		}
    		}
    	}
    	echo  json_encode($return);
    }
    /////////////////////////////////////////////
    function check_no_of_subject()
    {
    	$return = array();
    	$return['msg'] = '';
    	$return['error'] = false;
    	$academic_session=$this->input->post('academic_session');
        
    	$return['msg'] ="<table border='1' width='30%'>
    			<tr><th>Roll</th><th>Subject No</th>";
    	$group_id="Science";
    	$needAssign="8";
    	$result=$this->student_model->check_no_of_subject($academic_session,$group_id,$needAssign);
    	
    	foreach($result as $row)
    	{
    		$return['msg'].="<tr><td>".$row['student_id']."</td><td>".$row['noofsubjet']."</td></tr>";
    	}
    	
    	$group_id="Humanities";
    	$needAssign="8";
    	$result=$this->student_model->check_no_of_subject($academic_session,$group_id,$needAssign);
    	 
    	foreach($result as $row)
    	{
    		$return['msg'].="<tr><td>".$row['student_id']."</td><td>".$row['noofsubjet']."</td></tr>";
    	}
    	
    	$group_id="Business Studies";
    	$needAssign="8";
    	$result=$this->student_model->check_no_of_subject($academic_session,$group_id,$needAssign);
    	 
    	foreach($result as $row)
    	{
    		$return['msg'].="<tr><td>".$row['student_id']."</td><td>".$row['noofsubjet']."</td></tr>";
    	}
    	
    	$return['msg'].="</table>";
    	echo  json_encode($return);
    }
    ///////////////////////////////////////////
    function load_html_std_marks_view()
    {
    	if($this->input->post('exam_name')=="first_term")
    	{
    	  $data["first_term_data"]=$this->student_model->get_std_MarksDetail_by_studentID($this->input->post('student_id'),$this->input->post('academic_session'));
          $this->load->view('admin/student/marks_update_first_term',$data);    
    	}
    	else if($this->input->post('exam_name')=="pro_test")
    	{
    	  $data["pro_test_data"]=$this->student_model->get_std_MarksDetail_by_studentID($this->input->post('student_id'),$this->input->post('academic_session'));
          $this->load->view('admin/student/marks_update_pro_test',$data); 
    	} 
    	else if($this->input->post('exam_name')=="pre_test")
    	{
    		$data["pre_test_data"]=$this->student_model->get_std_MarksDetail_by_studentID($this->input->post('student_id'),$this->input->post('academic_session'));
    		$this->load->view('admin/student/marks_update_pre_test',$data);
    	}
    	else if($this->input->post('exam_name')=="test_exam")
    	{
    		$data["test_exam_data"]=$this->student_model->get_std_MarksDetail_by_studentID($this->input->post('student_id'),$this->input->post('academic_session'));
    		$this->load->view('admin/student/marks_update_test_exam',$data);
    	}
    	else {}
    }
  ///////////////////////////////////////////
    function update_std_marks_view()
    {
    	
    	 $data['main_content'] = 'admin/student/update_std_marks_view';
         $this->load->view('includes/template2', $data);    
    	 
    }
    /////////////////////////////////////////////
    ///////////////For First Term Exam////////////
    ////////////////////////////////////////////////
    function update_std_first_term_marks()
     {
	    //error_log("validation start...", 3, "my-errors.log");
	    $return = array();
        $return['msg'] = '';
        $return['error'] = false;
        try{	    
            //form validation
	    $this->load->library('form_validation');
	    //->form_validation->set_rules('f_y_1st_att[]', 'f_y_1st_att', 'numeric');
	    $this->form_validation->set_rules('f_y_1st_ct[]', 'f_y_1st_ct', 'numeric');
	    //$this->form_validation->set_rules('f_y_1st_ht_mcq[]', 'f_y_1st_ht_mcq', 'numeric');
	    //$this->form_validation->set_rules('f_y_1st_ht_cq[]', 'f_y_1st_ht_cq', 'numeric');
	   
	    //if the form has passed through the validation

	    if ($this->form_validation->run())
	    {
		//error_log("validation end...", 3, "my-errors.log");
		$student_id=$this->input->post('real_student_id');
		$academic_session=$this->input->post('academic_session');
		    
		$subject_id = $this->input->post('subject_id');
		$f_y_1st_att = $this->input->post('f_y_1st_att');
		$f_y_1st_ct = $this->input->post('f_y_1st_ct');
		$f_y_1st_ht_mcq = $this->input->post('f_y_1st_ht_mcq');
		$f_y_1st_ht_cq = $this->input->post('f_y_1st_ht_cq');
		$f_y_1st_ht_total = $this->input->post('f_y_1st_ht_total');
		$f_y_1st_gran_total = $this->input->post('f_y_1st_gran_total');
    
		foreach( $subject_id as $key => $sub_id )
		{
		  $data_for_update = array(		    
					'f_y_1st_att' => ($f_y_1st_att[$key]=='' ? null:$f_y_1st_att[$key]),
					'f_y_1st_ct' => ($f_y_1st_ct[$key]==''?null:$f_y_1st_ct[$key]),
					'f_y_1st_ht_mcq' => ($f_y_1st_ht_mcq[$key]==''?null:$f_y_1st_ht_mcq[$key]),
					'f_y_1st_ht_cq' => ($f_y_1st_ht_cq[$key]==''?null:$f_y_1st_ht_cq[$key]),
		  		    'f_y_1st_ht_total' => ($f_y_1st_ht_total[$key]==''?null:$f_y_1st_ht_total[$key]),
		  		    'f_y_1st_gran_total' => ($f_y_1st_gran_total[$key]==''?null:$f_y_1st_gran_total[$key])
					);
		  if($this->student_model->update_exam_marks($student_id,$academic_session,$sub_id,$data_for_update) == true)
		    {
			 $return['msg']="Update Succefully";
		    }
		 else{
			$return['msg']="Update Failed";
			break;
		     }
		}//end foreach
    
	    }//validation run
	    else{
	     $return['msg']=validation_errors();
	    }
         }
	catch(Exception $e)
	  {
	   $return['msg']=$e->getMessage();
	  }
	
	echo  json_encode($return);
     }	
	///////////////////////////////////////////
	//////////////Promotion Test Exam//////////
     /////////////////////////////////////////////
     function update_std_pro_test_marks()
     {
     	//error_log("validation start...", 3, "my-errors.log");
     	$return = array();
     	$return['msg'] = '';
     	$return['error'] = false;
     	try{
     		//form validation
     		$this->load->library('form_validation');
     		//$this->form_validation->set_rules('f_y_pro_ht_total[]', 'f_y_pro_ht_total', 'numeric');
     		//if the form has passed through the validation  
     		//if ($this->form_validation->run())
     		if (true)
     		{
     			//error_log("validation end...", 3, "my-errors.log");
     			$student_id=$this->input->post('real_student_id');
     			$academic_session=$this->input->post('academic_session');
     
     			$subject_id = $this->input->post('subject_id');
     			$f_y_pro_att = $this->input->post('f_y_pro_att');
     			$f_y_pro_ht_mcq = $this->input->post('f_y_pro_ht_mcq');
     			$f_y_pro_ht_cq = $this->input->post('f_y_pro_ht_cq');
     			$f_y_pro_ht_prac = $this->input->post('f_y_pro_ht_prac');
     			$f_y_pro_ht_total = $this->input->post('f_y_pro_ht_total');
     			$f_y_pro_gpa = $this->input->post('f_y_pro_gpa');
     
     			foreach( $subject_id as $key => $sub_id )
     			{
     		  $data_for_update = array(
     		  		'f_y_pro_att' => ($f_y_pro_att[$key]=='' ? null:$f_y_pro_att[$key]),
     		  		'f_y_pro_ht_mcq' => ($f_y_pro_ht_mcq[$key]==''?null:$f_y_pro_ht_mcq[$key]),
     		  		'f_y_pro_ht_cq' => ($f_y_pro_ht_cq[$key]==''?null:$f_y_pro_ht_cq[$key]),
     		  		'f_y_pro_ht_prac' => ($f_y_pro_ht_prac[$key]==''?null:$f_y_pro_ht_prac[$key]),
     		  		'f_y_pro_ht_total' => ($f_y_pro_ht_total[$key]==''?null:$f_y_pro_ht_total[$key]),
     		  		'f_y_pro_gpa' => ($f_y_pro_gpa[$key]==''?null:$f_y_pro_gpa[$key])
     		  );
     		  if($this->student_model->update_exam_marks($student_id,$academic_session,$sub_id,$data_for_update) == true)
     		  {
     		  	$return['msg']="Update Succefully";
     		  }
     		  else{
     		  	$return['msg']="Update Failed";
     		  	break;
     		  }
     			}//end foreach
     
     		}//validation run
     		else{
     			$return['msg']=$this->form_validation->error_array();
     		}
     	}
     	catch(Exception $e)
     	{
     		$return['msg']=$e->getMessage();
     	}
     
     	echo  json_encode($return);
     }
     ///////////////////////////////////////////
     ///////////Pre-Test Exam/////////////////
     /////////////////////////////////////////////
     function update_std_pre_test_marks()
     {
     	//error_log("validation start...", 3, "my-errors.log");
     	$return = array();
     	$return['msg'] = '';
     	$return['error'] = false;
     	try{
     		//form validation
     		$this->load->library('form_validation');
     		//if the form has passed through the validation
     		 
     		//if ($this->form_validation->run())
     		if(true)	
     		{
     			//error_log("validation end...", 3, "my-errors.log");
     			$student_id=$this->input->post('real_student_id');
     			$academic_session=$this->input->post('academic_session');
     			 
     			$subject_id = $this->input->post('subject_id');
     			$s_y_pre_att = $this->input->post('s_y_pre_att');
     			$s_y_pre_ct = $this->input->post('s_y_pre_ct');
     			$s_y_pre_ht_mcq = $this->input->post('s_y_pre_ht_mcq');
     			$s_y_pre_ht_cq = $this->input->post('s_y_pre_ht_cq');
     			$s_y_pre_ht_total = $this->input->post('s_y_pre_ht_total');
     			$s_y_pre_gran_total = $this->input->post('s_y_pre_gran_total');
     			 
     			foreach( $subject_id as $key => $sub_id )
     			{
     				$data_for_update = array(
     						's_y_pre_att' => ($s_y_pre_att[$key]=='' ? null:$s_y_pre_att[$key]),
     						's_y_pre_ct' => ($s_y_pre_ct[$key]==''?null:$s_y_pre_ct[$key]),
     						's_y_pre_ht_mcq' => ($s_y_pre_ht_mcq[$key]==''?null:$s_y_pre_ht_mcq[$key]),
     						's_y_pre_ht_cq' => ($s_y_pre_ht_cq[$key]==''?null:$s_y_pre_ht_cq[$key]),
     						's_y_pre_ht_total' => ($s_y_pre_ht_total[$key]==''?null:$s_y_pre_ht_total[$key]),
     						's_y_pre_gran_total' => ($s_y_pre_gran_total[$key]==''?null:$s_y_pre_gran_total[$key])
     				);
     				if($this->student_model->update_exam_marks($student_id,$academic_session,$sub_id,$data_for_update) == true)
     				{
     					$return['msg']="Update Succefully";
     				}
     				else{
     					$return['msg']="Update Failed";
     					break;
     				}
     			}//end foreach
     			 
     		}//validation run
     		else{
     			$return['msg']=$this->form_validation->error_array();
     		}
     	}
     	catch(Exception $e)
     	{
     		$return['msg']=$e->getMessage();
     	}
     	 
     	echo  json_encode($return);
     }
     ///////////////////////////////////////////
     /////////////////////////////////////////////
     function update_std_test_exam_marks()
     {
     	//error_log("validation start...", 3, "my-errors.log");
     	$return = array();
     	$return['msg'] = '';
     	$return['error'] = false;
     	try{
     		//form validation
     		$this->load->library('form_validation');
     		/* $this->form_validation->set_rules('f_y_1st_att[]', 'f_y_1st_att', 'numeric');
     		 $this->form_validation->set_rules('f_y_1st_ct[]', 'f_y_1st_ct', 'numeric');
     		$this->form_validation->set_rules('f_y_1st_ht_mcq[]', 'f_y_1st_ht_mcq', 'numeric');
     		$this->form_validation->set_rules('f_y_1st_ht_cq[]', 'f_y_1st_ht_cq', 'numeric');
     		*/
     		//if the form has passed through the validation
     
     		//if ($this->form_validation->run())
     		if(true)	
     		{
     			//error_log("validation end...", 3, "my-errors.log");
     			$student_id=$this->input->post('real_student_id');
     			$academic_session=$this->input->post('academic_session');
     			 
     			$subject_id = $this->input->post('subject_id');
     			$s_y_test_att = $this->input->post('s_y_test_att');
     			$s_y_t_p1_mcq = $this->input->post('s_y_t_p1_mcq');
     			$s_y_t_p1_cq = $this->input->post('s_y_t_p1_cq');
     			$s_y_t_p1_total = $this->input->post('s_y_t_p1_total');
     			$s_y_t_p2_mcq = $this->input->post('s_y_t_p2_mcq');
     			$s_y_t_p2_cq = $this->input->post('s_y_t_p2_cq');
     			$s_y_t_p2_total = $this->input->post('s_y_t_p2_total');
     			$s_y_test_gra_total = $this->input->post('s_y_test_gra_total');
     			$s_y_test_gpa = $this->input->post('s_y_test_gpa');
     			 
     			foreach( $subject_id as $key => $sub_id )
     			{
     				$data_for_update = array(
     						's_y_test_att' => ($s_y_test_att[$key]=='' ? null:$s_y_test_att[$key]),
     						's_y_t_p1_mcq' => ($s_y_t_p1_mcq[$key]==''?null:$s_y_t_p1_mcq[$key]),
     						's_y_t_p1_cq' => ($s_y_t_p1_cq[$key]==''?null:$s_y_t_p1_cq[$key]),
     						's_y_t_p1_total' => ($s_y_t_p1_total[$key]==''?null:$s_y_t_p1_total[$key]),
     						's_y_t_p2_mcq' => ($s_y_t_p2_mcq[$key]==''?null:$s_y_t_p2_mcq[$key]),
     						's_y_t_p2_cq' => ($s_y_t_p2_cq[$key]==''?null:$s_y_t_p2_cq[$key]),
     						's_y_t_p2_total' => ($s_y_t_p2_total[$key]==''?null:$s_y_t_p2_total[$key]),
     						's_y_test_gra_total' => ($s_y_test_gra_total[$key]==''?null:$s_y_test_gra_total[$key]),
     						's_y_test_gpa' => ($s_y_test_gpa[$key]==''?null:$s_y_test_gpa[$key])
     				);
     				if($this->student_model->update_exam_marks($student_id,$academic_session,$sub_id,$data_for_update) == true)
     				{
     					$return['msg']="Update Succefully";
     				}
     				else{
     					$return['msg']="Update Failed";
     					break;
     				}
     			}//end foreach
     			 
     		}//validation run
     		else{
     			$return['msg']=$this->form_validation->error_array();
     		}
     	}
     	catch(Exception $e)
     	{
     		$return['msg']=$e->getMessage();
     	}
     	 
     	echo  json_encode($return);
     }
     ///////////////////////////////////////////
	 /////////////////////////////////////////////
    function store_std_general_info()
     {
	    //error_log("validation start...", 3, "my-errors.log");
	    $return = array();
        $return['msg'] = '';
        $return['error'] = false;
        try{	    
            //form validation
	    $this->load->library('form_validation');
	    $this->form_validation->set_rules('student_name', 'student_name', 'required');
	    $this->form_validation->set_rules('student_id', 'f_y_1st_ct', 'required');
	    $this->form_validation->set_rules('academic_session', 'f_y_1st_ht_mcq', 'required');
	    $this->form_validation->set_rules('mother_lang', 'f_y_1st_ht_cq', 'required');
	    //if the form has passed through the validation

	    if ($this->form_validation->run())
	    {
		error_log("validation end...", 3, "my-errors.log");
		  $data_for_insert_general = array(		    
					'student_id' => $this->input->post('student_id'),
					'group_id' => $this->input->post('group_id'),					
					'student_name' => $this->input->post('student_name'),
					'academic_session' => $this->input->post('academic_session'),
					'mother_lang' => $this->input->post('mother_lang'),
					'fathername' => $this->input->post('fathername'),
					'mothername' => $this->input->post('mothername'),
					'dob' => $this->input->post('dob'),
					'dateofadmission' => $this->input->post('dateofadmission'),
					'presentaddress' => $this->input->post('presentaddress'),
					'phone_reg' => $this->input->post('phone_reg'),
					'phone_off' => $this->input->post('phone_off'),					
			  		'transfer_no' => $this->input->post('transfer_no'),
			  		'trans_date' => $this->input->post('trans_date'),
			  		'dropped' => $this->input->post('dropped'),
			  		'drop_date' => $this->input->post('drop_date'),
			  		'co_cur_activities' => $this->input->post('co_cur_activities')
					);
		  $data_for_insert_edu = array(
		  		    'student_id' => $this->input->post('student_id'),
		  		    'academic_session' => $this->input->post('academic_session'),
		  		    'ssc_board' => $this->input->post('ssc_board'),
					'ssc_year' => $this->input->post('ssc_year'),
					'ssc_group' => $this->input->post('ssc_group'),
					'ssc_reg_no' => $this->input->post('ssc_reg_no'),
					'ssc_reg_year' => $this->input->post('ssc_reg_year'),
					'ssc_centre' => $this->input->post('ssc_centre'),
					'ssc_roll' => $this->input->post('ssc_roll'),
					'ssc_gpa' => $this->input->post('ssc_gpa'),
					'ssc_opt' => $this->input->post('ssc_opt'),
					'ssc_school' => $this->input->post('ssc_school'),
					'hsc_board' => $this->input->post('hsc_board'),
					'hsc_year' => $this->input->post('hsc_year'),
					'hsc_group' => $this->input->post('hsc_group'),
					'hsc_reg_no' => $this->input->post('hsc_reg_no'),
					'hsc_reg_year' => $this->input->post('hsc_reg_year'),
					'hsc_centre' => $this->input->post('hsc_centre'),
		  		    'hsc_roll' => $this->input->post('hsc_roll'),
			  		'hsc_gpa' => $this->input->post('hsc_gpa'),
			  		'hsc_opt' => $this->input->post('hsc_opt'),
			  		'hsc_medium' => $this->input->post('hsc_medium')
		  		    );
		  
		  if($this->student_model->insert_std_general_info($data_for_insert_general)
		     &&  $this->student_model->insert_std_edu_info($data_for_insert_edu)
		     &&  $this->student_model->insert_std_exam_merit($data_for_insert_edu)	     
		  )
		    {
			 $return['msg']="Insert Succefully";
		    }
		 else{
			$return['msg']="Insert Failed";
			break;
		     }

	    }//validation run
	    else{
	     $return['msg']=$this->form_validation->error_array();
	    }
         }
	catch(Exception $e)
	  {
	   $return['msg']=$e->getMessage();
	  }
	
	echo  json_encode($return);
     }	
     /////////////////////////////////////////
     function add_subject_view()
     {
     	$data['main_content'] = 'admin/student/add_subject_view';
     	$this->load->view('includes/template2', $data);
     }
     /////////////////////////////////////////
     function store_new_subject()
     {
     	//error_log("validation start...", 3, "my-errors.log");
	    $return = array();
        $return['msg'] = '';
        $return['error'] = false;
        try{	    
            //form validation
	    $this->load->library('form_validation');
	    $this->form_validation->set_rules('subject_name', 'subject_name', 'required');
	    $this->form_validation->set_rules('subject_id', 'subject_id', 'required');
	    //if the form has passed through the validation

	    if ($this->form_validation->run())
	    {
		  //error_log("validation end...", 3, "my-errors.log");
		  $data_for_insert_subject = array(		    
					'subject_id' => $this->input->post('subject_id'),
					'group_id' => $this->input->post('group_id'),					
					'subject_name' => $this->input->post('subject_name'),
					'subj_sort_name' => $this->input->post('subj_sort_name'),
					'subj_code' => $this->input->post('subj_code'),
					'subject_order' => $this->input->post('subject_order'),
					'is_core' => $this->input->post('is_core')
					);
		  
		  
		  if($this->student_model->insert_new_subject($data_for_insert_subject) )
		    {
			 $return['msg']="Insert Succefully";
		    }
		 else{
			$return['msg']="Insert Failed";
			break;
		     }

	    }//validation run
	    else{
	     $return['msg']=$this->form_validation->error_array();
	    }
      }
	  catch(Exception $e)
	  {
	   $return['msg']=$e->getMessage();
	  }
	
	  echo  json_encode($return);
     }
     //////////////////////////////////////////
     function subject_total_attendence_view()
     {
     	$code_subject=$this->student_model->get_subject();
     	$data['code_subject']=$code_subject;
     	$data['main_content'] = 'admin/student/subject_total_attendence_view';
     	$this->load->view('includes/template2', $data);
     }
     //////////////////////////////////////////
     function subject_total_attendence_sel()
     {
     	$return = array();
     	$return['msg'] = '';
     	$return['error'] = false;
     	
     	$subject_att=$this->student_model->subject_total_attendence();
     	$return['msg'] = $subject_att;
     	
     	 echo  json_encode($return);
     }
     //////////////////////////////////////////
     function show_all_attendence()
     {
     	$all_attendence=$this->student_model->get_all_attendence();
     	$data['all_attendence']=$all_attendence;
     	$this->load->view('admin/student/show_all_attendence_vew', $data);
     }
     ////////////////////////////////////////////////
     function subject_total_attendence_store()
     {
     	$return = array();
     	$return['msg'] = '';
     	$return['error'] = false;
     	try{
     		//form validation
     		$this->load->library('form_validation');
     		$this->form_validation->set_rules('group_id', 'group_id', 'required');
     		$this->form_validation->set_rules('section', 'section', 'required');
     		$this->form_validation->set_rules('exam_name', 'exam_name', 'required');
     		$this->form_validation->set_rules('no_of_class', 'no_of_class', 'required|numeric');
     		//if the form has passed through the validation
     	
     		if ($this->form_validation->run())
     		{
     			$exam_name=$this->input->post('exam_name');
     			if($exam_name=="first_term")
     				$exam_name="f_y_1st_t_att";
     			elseif ($exam_name=="pro_test")
     			  $exam_name="f_y_pro_t_att";
     			elseif ($exam_name=="pre_test")
     			  $exam_name="s_y_pre_t_att";
     			elseif ($exam_name=="test_exam")
     			  $exam_name="s_y_test_t_att";
     			else {
     				$exam_name="";
     			}
     			$data_for_insert_update = array(
     					'subject_id' => $this->input->post('subject_id'),
     					'group_id' => $this->input->post('group_id'),
     					'academic_session' => $this->input->post('academic_session'),
     					'section' => $this->input->post('section'),
     					$exam_name=> $this->input->post('no_of_class'),
     					'col_name'=>$exam_name,
     					'col_value' => $this->input->post('no_of_class')
     			);
     	
     	
     			if($this->student_model->insert_update_no_of_class($data_for_insert_update))
     			{
     				$return['msg']="Insert Succefully";
     			}
     			else{
     				$return['msg']="Insert Failed";
     			}
     	
     		}//validation run
     		else{
     			$return['msg']=$this->form_validation->error_array();
     		}
     	}
     	catch(Exception $e)
     	{
     		$return['msg']=$e->getMessage();
     	}
     	
     	echo  json_encode($return);
     }
     /////////////////////////////////////////////
     function update_total_exam_marks_view()
     {
     	$data['main_content'] = 'admin/student/update_total_exam_marks_view';
     	$this->load->view('includes/template2', $data);
     }
     //////////////////////////////////////////
     function load_html_total_exam_marks_view()
     {
     	$data["total_exam_marks_data"]=$this->student_model->get_exam_total_marksByGroupID($this->input->post('group_id'));
     	$this->load->view('admin/student/total_exam_marks_view',$data);
     }
     function update_total_exam_marks()
     {
     	//error_log("validation start...", 3, "my-errors.log");
     	$return = array();
     	$return['msg'] = '';
     	$return['error'] = false;
     	try{
     		//form validation
     		$this->load->library('form_validation');
     
     		$this->form_validation->set_rules('f_y_1st_ct[]', 'f_y_1st_ct', 'numeric');
     		//$this->form_validation->set_rules('f_y_1st_ht_mcq[]', 'f_y_1st_ht_mcq', 'numeric');
     		//$this->form_validation->set_rules('f_y_1st_ht_cq[]', 'f_y_1st_ht_cq', 'numeric');
     
     		//if the form has passed through the validation
     
     		if ($this->form_validation->run())
     		{
     			//error_log("validation end...", 3, "my-errors.log");
     			$group_id=$this->input->post('group_id');
     
     			$subject_id = $this->input->post('subject_id');
     			$f_y_1st_ct = $this->input->post('f_y_1st_ct');
     			$f_y_1st_ht_mcq = $this->input->post('f_y_1st_ht_mcq');
     			$f_y_1st_ht_cq = $this->input->post('f_y_1st_ht_cq');
     			$f_y_1st_ht_total = $this->input->post('f_y_1st_ht_total');
     			$f_y_1st_gran_total = $this->input->post('f_y_1st_gran_total');
     
     			$f_y_pro_ht_mcq = $this->input->post('f_y_pro_ht_mcq');
     			$f_y_pro_ht_cq = $this->input->post('f_y_pro_ht_cq');
     			$f_y_pro_ht_prac = $this->input->post('f_y_pro_ht_prac');
     			$f_y_pro_ht_total = $this->input->post('f_y_pro_ht_total');
     
     
     			$s_y_pre_ct = $this->input->post('s_y_pre_ct');
     			$s_y_pre_ht_mcq = $this->input->post('s_y_pre_ht_mcq');
     			$s_y_pre_ht_cq = $this->input->post('s_y_pre_ht_cq');
     			$s_y_pre_ht_total = $this->input->post('s_y_pre_ht_total');
     			$s_y_pre_gran_total = $this->input->post('s_y_pre_gran_total');
     
     
     			$s_y_t_p1_mcq = $this->input->post('s_y_t_p1_mcq');
     			$s_y_t_p1_cq = $this->input->post('s_y_t_p1_cq');
     			$s_y_t_p1_total = $this->input->post('s_y_t_p1_total');
     			$s_y_t_p2_mcq = $this->input->post('s_y_t_p2_mcq');
     			$s_y_t_p2_cq = $this->input->post('s_y_t_p2_cq');
     			$s_y_t_p2_total = $this->input->post('s_y_t_p2_total');
     			$s_y_test_gra_total = $this->input->post('s_y_test_gra_total');
     
     
     			foreach( $subject_id as $key => $sub_id )
     			{
     				$data_for_update = array(
     						'f_y_1st_ct' => ($f_y_1st_ct[$key]==''?null:$f_y_1st_ct[$key]),
     						'f_y_1st_ht_mcq' => ($f_y_1st_ht_mcq[$key]==''?null:$f_y_1st_ht_mcq[$key]),
     						'f_y_1st_ht_cq' => ($f_y_1st_ht_cq[$key]==''?null:$f_y_1st_ht_cq[$key]),
     						'f_y_1st_ht_total' => ($f_y_1st_ht_total[$key]==''?null:$f_y_1st_ht_total[$key]),
     						'f_y_1st_gran_total' => ($f_y_1st_gran_total[$key]==''?null:$f_y_1st_gran_total[$key]),
     						'f_y_pro_ht_mcq' => ($f_y_pro_ht_mcq[$key]==''?null:$f_y_pro_ht_mcq[$key]),
     						'f_y_pro_ht_cq' => ($f_y_pro_ht_cq[$key]==''?null:$f_y_pro_ht_cq[$key]),
     						'f_y_pro_ht_prac' => ($f_y_pro_ht_prac[$key]==''?null:$f_y_pro_ht_prac[$key]),
     						'f_y_pro_ht_total' => ($f_y_pro_ht_total[$key]==''?null:$f_y_pro_ht_total[$key]),
     						's_y_pre_ct' => ($s_y_pre_ct[$key]==''?null:$s_y_pre_ct[$key]),
     						's_y_pre_ht_mcq' => ($s_y_pre_ht_mcq[$key]==''?null:$s_y_pre_ht_mcq[$key]),
     						's_y_pre_ht_cq' => ($s_y_pre_ht_cq[$key]==''?null:$s_y_pre_ht_cq[$key]),
     						's_y_pre_ht_total' => ($s_y_pre_ht_total[$key]==''?null:$s_y_pre_ht_total[$key]),
     						's_y_pre_gran_total' => ($s_y_pre_gran_total[$key]==''?null:$s_y_pre_gran_total[$key]),
     						's_y_t_p1_mcq' => ($s_y_t_p1_mcq[$key]==''?null:$s_y_t_p1_mcq[$key]),
     						's_y_t_p1_cq' => ($s_y_t_p1_cq[$key]==''?null:$s_y_t_p1_cq[$key]),
     						's_y_t_p1_total' => ($s_y_t_p1_total[$key]==''?null:$s_y_t_p1_total[$key]),
     						's_y_t_p2_mcq' => ($s_y_t_p2_mcq[$key]==''?null:$s_y_t_p2_mcq[$key]),
     						's_y_t_p2_cq' => ($s_y_t_p2_cq[$key]==''?null:$s_y_t_p2_cq[$key]),
     						's_y_t_p2_total' => ($s_y_t_p2_total[$key]==''?null:$s_y_t_p2_total[$key]),
     						's_y_test_gra_total' => ($s_y_test_gra_total[$key]==''?null:$s_y_test_gra_total[$key])
     				);
     				if($this->student_model->update_total_exam_marks($group_id,$sub_id,$data_for_update) == true)
     				{
     					$return['msg']="Update Succefully";
     				}
     				else{
     					$return['msg']="Update Failed";
     					break;
     				}
     			}//end foreach
     
     		}//validation run
     		else{
     			$return['msg']=validation_errors();
     		}
     	}
     	catch(Exception $e)
     	{
     		$return['msg']=$e->getMessage();
     	}
     
     	echo  json_encode($return);
     }
     ///////////////////////////////////////////
	///////////////////////////////////////////
     function result_card_report()
     {
     	 
     	$data['main_content'] = 'admin/student/result_card_report_view';
     	$this->load->view('includes/template2', $data);
     
     }
     /////////////////////////////////////////////
     function result_process_view()
     {
     	$data['main_content'] = 'admin/student/result_process_view';
     	$this->load->view('includes/template2', $data);
     }
     /////////////////////////////////////////////
     function result_process()
     {
     	$return = array();
     	$return['msg'] = '';
     	$return['error'] = false;
     	$exam_name=$this->input->post('exam_name');
     	$academic_session=$this->input->post('academic_session');
     	$group_id=$this->input->post('group_id');
     	
     	if($exam_name=="first_term")
     	{
     	if($this->student_model->first_term_result_process($exam_name,$academic_session,$group_id))
     		$return['msg'] = "Result Processing Completed";
     	else 
     	  $return['msg'] = 'Result Processing not Completed';
     	}
     	
     	if($exam_name=="promotion_test")
     	{
     		if($this->student_model->promotion_test_result_process($exam_name,$academic_session,$group_id))
     			$return['msg'] = "Result Processing Completed";
     		else
     			$return['msg'] = 'Result Processing not Completed';
     	}
     	if($exam_name=="pre_test")
     	{
     		if($this->student_model->pre_test_result_process($exam_name,$academic_session,$group_id))
     			$return['msg'] = "Result Processing Completed";
     		else
     			$return['msg'] = 'Result Processing not Completed';
     	}
     	if($exam_name=="test_exam")
     	{
     		if($this->student_model->test_exam_result_process($exam_name,$academic_session,$group_id))
     			$return['msg'] = "Result Processing Completed";
     		else
     			$return['msg'] = 'Result Processing not Completed';
     	}
     	
     	
     	echo  json_encode($return);
     }
     /////////////////////////////////////////////
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */